home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performDisplayControl.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  23.8 KB  |  876 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  January 07, 1997
  22. //  Author:         ivn
  23. //
  24. //
  25. //  Description:
  26. //      Display Control option box script.
  27. //
  28. //  Input Arguments:
  29. //      bool        if true show option box
  30. //                    if false perform command with current values
  31. //  Return Value:
  32. //      none
  33. //
  34.  
  35.     global int $displayControlScopeCount = 5;
  36.  
  37. //
  38. //  Procedure Name:
  39. //      setOptionVars
  40. //
  41. //  Description:
  42. //        Initialize the option values.
  43. //
  44. //  Input Arguments:
  45. //        Whether to set the options to default values.
  46. //
  47. //  Return Value:
  48. //      None.
  49. //
  50. proc setOptionVars(int $forceFactorySettings)
  51. {
  52.     int $i;
  53.  
  54.     global int $displayControlScopeCount;
  55.  
  56.     if ($forceFactorySettings || !`optionVar -exists displayControlScope`) {
  57.         optionVar -intValue displayControlScope 1;
  58.     }
  59.  
  60.     //    Edit Points
  61.     //
  62.     if ($forceFactorySettings || !`optionVar -exists displayControlEditPoints`) {
  63.         optionVar -clearArray displayControlEditPoints;
  64.         for ($i = 0; $i < $displayControlScopeCount; $i++) {
  65.             optionVar -intValueAppend displayControlEditPoints false;
  66.         }
  67.     }
  68.  
  69.     //    Hulls
  70.     //
  71.     if ($forceFactorySettings || !`optionVar -exists displayControlHulls`) {
  72.         optionVar -clearArray displayControlHulls;
  73.         for ($i = 0; $i < $displayControlScopeCount; $i++) {
  74.             optionVar -intValueAppend displayControlHulls false;
  75.         }
  76.     }
  77.  
  78.     //    CVs
  79.     //
  80.     if ($forceFactorySettings || !`optionVar -exists displayControlCVs`) {
  81.         optionVar -clearArray displayControlCVs;
  82.         for ($i = 0; $i < $displayControlScopeCount; $i++) {
  83.             optionVar -intValueAppend displayControlCVs false;
  84.         }
  85.     }
  86.  
  87.     //    Normals
  88.     //
  89.     if ($forceFactorySettings || !`optionVar -exists displayControlNormals`) {
  90.         optionVar -clearArray displayControlNormals;
  91.         for ($i = 0; $i < $displayControlScopeCount; $i++) {
  92.             optionVar -intValueAppend displayControlNormals false;
  93.         }
  94.     }
  95.  
  96.     //    Faces
  97.     //
  98.     if ($forceFactorySettings ||
  99.         !`optionVar -exists displayControlSurfaceFace`) {
  100.         optionVar -clearArray displayControlSurfaceFace;
  101.         for ($i = 0; $i < $displayControlScopeCount; $i++) {
  102.             optionVar -intValueAppend displayControlSurfaceFace false;
  103.         }
  104.     }
  105.  
  106.     //    Origin
  107.     //
  108.     if ($forceFactorySettings ||
  109.         !`optionVar -exists displayControlOrigin`) {
  110.         optionVar -clearArray displayControlOrigin;
  111.         for ($i = 0; $i < $displayControlScopeCount; $i++) {
  112.             optionVar -intValueAppend displayControlOrigin false;
  113.         }
  114.     }
  115.  
  116.     //    Selection Handles
  117.     //
  118.     if ($forceFactorySettings || !`optionVar -exists displayControlSelectHandles`) {
  119.         optionVar -clearArray displayControlSelectHandles;
  120.         for ($i = 0; $i < $displayControlScopeCount; $i++) {
  121.             optionVar -intValueAppend displayControlSelectHandles false;
  122.         }
  123.     }
  124.  
  125.     //    All ON
  126.     //
  127.     if ($forceFactorySettings || !`optionVar -exists displayControlAllON`) {
  128.         optionVar -intValue displayControlAllON false;
  129.     }
  130.  
  131.     //    All OFF
  132.     //
  133.     if ($forceFactorySettings || !`optionVar -exists displayControlAllOFF`) {
  134.         optionVar -intValue displayControlAllOFF false;
  135.     }
  136. }
  137.  
  138. //
  139. //  Procedure Name:
  140. //      displayControlSetup
  141. //
  142. //  Description:
  143. //        Update the state of the option box UI to reflect the option values.
  144. //
  145. //  Input Arguments:
  146. //      parent               - Top level parent layout of the option box UI.
  147. //                             Required so that UI object names can be 
  148. //                             successfully resolved.
  149. //
  150. //    forceFactorySettings - Whether the option values should be set to
  151. //                             default values.
  152. //
  153. //  Return Value:
  154. //      None.
  155. //
  156. global proc displayControlSetup(string $parent, int $forceFactorySettings)
  157. {
  158.     //    Retrieve the option settings
  159.     //
  160.     setOptionVars($forceFactorySettings);
  161.  
  162.     setParent $parent;
  163.  
  164.     // Retrieve the option settings
  165.     //
  166.     setOptionVars ($forceFactorySettings);
  167.     setParent $parent;
  168.     // print ( $parent + "\n" );
  169.  
  170.     // Scope Pop-up
  171.     //
  172.     optionMenuGrp -e -sl `optionVar -q displayControlScope` scopePopup;
  173.     int $index = `optionVar -q displayControlScope`; 
  174.     tabLayout -e -sti $index displayTabs;
  175.     $index--;   // to make it 0-based
  176.  
  177.     displayControlSetUpHelper "active_tab"         0;
  178.     displayControlSetUpHelper "all_tab"         1;
  179.     displayControlSetUpHelper "NewCurve_tab"     2;
  180.     if( `isTrue SurfaceUIExists` ) {
  181.         displayControlSetUpHelper "NewSurface_tab"     3;
  182.     }
  183. }
  184.  
  185. //
  186. //  Procedure Name:
  187. //      displayControlCallback
  188. //
  189. //  Description:
  190. //        Update the option values with the current state of the option box UI.
  191. //
  192. //  Input Arguments:
  193. //      parent - Top level parent layout of the option box UI.  Required so
  194. //               that UI object names can be successfully resolved.
  195. //
  196. //    doIt   - Whether the command should execute.
  197. //
  198. //  Return Value:
  199. //      None.
  200. //
  201. global proc displayControlCallback(string $parent, int $doIt)
  202. {
  203.     global int $displayControlScopeCount;
  204.     setParent $parent;
  205.  
  206.     // Set the optionVar's from the control values, and then perform the command
  207.     //
  208.  
  209.     //  Scope Pop-up
  210.     //
  211.     int $scopeValue = `optionMenuGrp -q -sl scopePopup`;
  212.     optionVar -intValue displayControlScope $scopeValue;
  213.     $scopeValue--;   // to make it 0-based
  214.  
  215.     // Set the parent to be the current tab
  216.     //
  217.     string $currentTab = `tabLayout -q -st displayTabs`;
  218.     setParent $currentTab;
  219.  
  220.     // Set the optionvars for the current tab
  221.     //
  222.     int $editPoints[] = `optionVar -q displayControlEditPoints`;
  223.     $editPoints[$scopeValue] = `checkBoxGrp -q -v1 editPointsCheck`;
  224.     optionVar -clearArray displayControlEditPoints;
  225.  
  226.     int $hulls[] = `optionVar -q displayControlHulls`;
  227.     $hulls[$scopeValue] = `checkBoxGrp -q -v1 hullsCheck`;
  228.     optionVar -clearArray displayControlHulls;
  229.  
  230.     int $cvs[] = `optionVar -q displayControlCVs`;
  231.     $cvs[$scopeValue] = `checkBoxGrp -q -v1 CVsCheck`;
  232.     optionVar -clearArray displayControlCVs;
  233.  
  234.     int $normals[] = `optionVar -q displayControlNormals`;
  235.     if( `isTrue SurfaceUIExists` ) {
  236.         $normals[$scopeValue] = `checkBoxGrp -q -v1 normalsCheck`;
  237.     }
  238.     else {
  239.         $normals[$scopeValue] = 0;
  240.     }
  241.     optionVar -clearArray displayControlNormals;
  242.  
  243.     int $sf[] = `optionVar -q displayControlSurfaceFace`;
  244.     $sf[$scopeValue] = `checkBoxGrp -q -v1 SurfaceFaceCheck`;
  245.     optionVar -clearArray displayControlSurfaceFace;
  246.  
  247.     int $origin[] = `optionVar -q displayControlOrigin`;
  248.     if( `isTrue SurfaceUIExists` ) {
  249.         $origin[$scopeValue] = `checkBoxGrp -q -v1 originCheck`;
  250.     } else {
  251.         $origin[$scopeValue] = 0;
  252.     }
  253.     optionVar -clearArray displayControlOrigin;
  254.  
  255.     int $selectHandles[] = `optionVar -q displayControlSelectHandles`;
  256.     $selectHandles[$scopeValue] = `checkBoxGrp -q -v1 selectHandlesCheck`;
  257.     optionVar -clearArray displayControlSelectHandles;
  258.  
  259.     for ($i = 0; $i < $displayControlScopeCount; $i++) {
  260.         optionVar -intValueAppend displayControlEditPoints $editPoints[$i];
  261.         optionVar -intValueAppend displayControlHulls $hulls[$i];
  262.         optionVar -intValueAppend displayControlCVs $cvs[$i];
  263.         optionVar -intValueAppend displayControlNormals $normals[$i];
  264.         optionVar -intValueAppend displayControlSurfaceFace $sf[$i];
  265.         optionVar -intValueAppend displayControlOrigin $origin[$i];
  266.         optionVar -intValueAppend displayControlSelectHandles $selectHandles[$i];
  267.     }
  268.  
  269.     if ($doIt) {
  270.         performDisplayControl 0; 
  271.         addToRecentCommandQueue "performDisplayControl 0" "DisplayControl";
  272.     }
  273. }
  274.  
  275. //
  276. //  Procedure Name:
  277. //      performDisplayControlOptions
  278. //
  279. //  Description:
  280. //        Construct the option box UI.  Involves accessing the standard option
  281. //        box and customizing the UI accordingly.
  282. //
  283. //  Input Arguments:
  284. //      None.
  285. //
  286. //  Return Value:
  287. //      None.
  288. //
  289. proc displayControlOptions()
  290. {
  291.     //    Name of the command for this option box.
  292.     //
  293.     string $commandName = "displayControl";
  294.  
  295.     //    Build the option box actions.
  296.     //
  297.     string $callback = ($commandName + "Callback");
  298.     string $setup = ($commandName + "Setup");
  299.  
  300.     //    STEP 1:  Get the option box.
  301.     //    ============================
  302.     //
  303.     //    The value returned is the name of the layout to be used as
  304.     //    the parent for the option box UI.
  305.     //
  306.     string $layout = getOptionBox();
  307.     setParent $layout;
  308.     
  309.     //    STEP 2:  Pass the command name to the option box - see STEP 8.
  310.     //    ==============================================================
  311.     
  312.     //    STEP 3:  Activate the default UI template.
  313.     //    ==========================================
  314.     //
  315.     //    Activate the default UI template so that the layout of this 
  316.     //    option box is consistent with the layout of the rest of the 
  317.     //    application.
  318.     //
  319.     setUITemplate -pushTemplate DefaultTemplate;
  320.  
  321.     //    STEP 4: Create option box contents.
  322.     //    ===================================
  323.     //    
  324.     //    This, of course, will vary from option box to option box.    
  325.     
  326.     //    Turn on the wait cursor.
  327.     //
  328.     waitCursor -state 1;
  329.  
  330.     tabLayout -tabsVisible 0 -scrollable 1;
  331.     
  332.     string $parent = `columnLayout -adjustableColumn 1`;
  333.     
  334.     optionMenuGrp -l "Scope" -cc displayControlEditOptions scopePopup;
  335.         menuItem -l "Active Objects" activeMenuItem;
  336.         menuItem -l "All Objects" allMenuItem;
  337.         menuItem -l "New Crv" newCrvMenuItem;
  338.         if( `isTrue SurfaceUIExists` ) {
  339.             menuItem -l "New Srf" newSrfMenuItem;
  340.         }
  341.     setParent -m ..;
  342.  
  343.     //
  344.     // Create tabs for all the buttons but only show one set of buttons
  345.     // Buttons displayed will change based on the menu above
  346.     //
  347.     tabLayout -tabsVisible false displayTabs;
  348.         columnLayout active_tab;
  349.             displayControlBuildButtons (`setParent -query`);
  350.         setParent ..;
  351.         columnLayout all_tab;
  352.             displayControlBuildButtons (`setParent -query`);
  353.         setParent ..;
  354.         columnLayout NewCurve_tab;
  355.             displayControlBuildButtons (`setParent -query`);
  356.         setParent ..;
  357.         columnLayout NewSurface_tab;
  358.             displayControlBuildButtons (`setParent -query`);
  359.         setParent ..;
  360.         setParent ..;
  361.     setParent;
  362.  
  363.     tabLayout -e
  364.         -tl active_tab "Active"
  365.         -tl all_tab "All"
  366.         -tl NewCurve_tab "New Curve"
  367.         -tl NewSurface_tab "New Surface"
  368.         displayTabs;
  369.     
  370.  
  371.     //    Turn off the wait cursor.
  372.     //
  373.     waitCursor -state 0;
  374.     
  375.     //    Step 5: Deactivate the default UI template.
  376.     //    ===========================================
  377.     //
  378.     setUITemplate -popTemplate;
  379.  
  380.     //    Step 6: Customize the buttons.  
  381.     //    ==============================
  382.     //
  383.     //    Provide more descriptive labels for the buttons.  This is not 
  384.     //    necessary, but in some cases, for example, a button labelled 
  385.     //    'Create' may be more meaningful to the user than one labelled
  386.     //    'Apply'.
  387.     //
  388.     //    Disable those buttons that are not applicable to the option box.
  389.     //
  390.     //    Attach actions to those buttons that are applicable to the option
  391.     //    box.  Note that the 'Close' button has a default action attached 
  392.     //    to it that will hide the window.  If a a custom action is
  393.     //    attached to the 'Close' button then be sure to call the 'hide the
  394.     //    option box' procedure within the custom action so that the option
  395.     //    box is hidden properly.
  396.  
  397.     //    'Apply' button.
  398.     //
  399.     string $applyBtn = getOptionBoxApplyBtn();
  400.     button -edit
  401.         -command ($callback + " " + $parent + " " + 1)
  402.         $applyBtn;
  403.  
  404.     //    'Save' button.
  405.     //
  406.     string $saveBtn = getOptionBoxSaveBtn();
  407.     button -edit 
  408.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  409.         $saveBtn;
  410.  
  411.     //    'Reset' button.
  412.     //
  413.     string $resetBtn = getOptionBoxResetBtn();
  414.     button -edit 
  415.         -command ($setup + " " + $parent + " " + 1)
  416.         $resetBtn;
  417.  
  418.     //    Step 7: Set the option box title.
  419.     //    =================================
  420.     //
  421.     setOptionBoxTitle("Display Control Options");
  422.  
  423.     //    Step 8: Customize the 'Help' menu item text.
  424.     //    ============================================
  425.     //
  426.     //    Set the command name for the option box, so that the Help menu
  427.     //    knows what command to get help for.
  428.     //
  429.     setOptionBoxCommandName("toggle");
  430.  
  431.  
  432.     //    Step 9: Set the current values of the option box.
  433.     //    =================================================
  434.     //
  435.     eval (($setup + " " + $parent + " " + 0));    
  436.     
  437.     //    Step 10: Show the option box.
  438.     //    =============================
  439.     //
  440.     showOptionBox();
  441. }
  442.  
  443. //
  444. //  Procedure Name:
  445. //      assembleCmd
  446. //
  447. //  Description:
  448. //        Construct the command that will apply the option box values.
  449. //
  450. //  Input Arguments:
  451. //      None.
  452. //
  453. proc string assembleCmd()
  454. {
  455.     string $cmd = "";
  456.  
  457.     setOptionVars(false);
  458.  
  459.     int     $scope                 = `optionVar -q displayControlScope`;
  460.     int     $editPoints[]         = `optionVar -q displayControlEditPoints`;
  461.     int     $hulls[]            = `optionVar -q displayControlHulls`;
  462.     int     $CVs[]                 = `optionVar -q displayControlCVs`;
  463.     int     $sf[]                 = `optionVar -q displayControlSurfaceFace`;
  464.     int     $origin[]             = `optionVar -q displayControlOrigin`;
  465.     int     $normals[]             = `optionVar -q displayControlNormals`;
  466.     int     $selectHandles[]     = `optionVar -q displayControlSelectHandles`;
  467.     if ($scope == 1) {
  468.  
  469.         // Work only on the active objects
  470.         //
  471.         // toggle -cv -ep -hull -normal -selectHandle -state false;
  472.         $cmd = "toggle -cv -state " + $CVs[0] + ";";
  473.         $cmd = $cmd + "toggle -ep -state " + $editPoints[0] + ";";
  474.         $cmd = $cmd + "toggle -hull -state " + $hulls[0] + ";";
  475.         $cmd = $cmd + "toggle -normal -state " + $normals[0] + ";";
  476.         $cmd = $cmd + "toggle -sf -state " + $sf[0] + ";";
  477.         $cmd = $cmd + "toggle -origin -state " + $origin[0] + ";";
  478.         $cmd = $cmd + "toggle -selectHandle -state " + $selectHandles[0] + ";";
  479.     }
  480.     else if ($scope == 2) {
  481.  
  482.         // Work on all the geometric objects 
  483.         //
  484.         string $gmtyObjs[] = `ls -g`;
  485.         // toggle -cv -ep -hull -normal -selectHandle -state false $gmtyObjs;
  486.         int $i, $n;
  487.         $n = size($gmtyObjs);
  488.  
  489.         if( $n > 0 ) {
  490.             $cmd = $cmd + "toggle -cv -state " + $CVs[1];
  491.             int $needEP = true;
  492.             int $needH = true;
  493.             int $needN = true;
  494.             int $needSF = true;
  495.             int $needOrigin = true;
  496.             if( $CVs[1] == $editPoints[1] ) {
  497.                 $cmd = $cmd + "-ep ";
  498.                 $needEP = false;
  499.             }
  500.             if( $CVs[1] == $hulls[1] ) {
  501.                 $cmd = $cmd + "-hull ";
  502.                 $needH = false;
  503.             }
  504.             if( $CVs[1] == $normals[1] ) {
  505.                 $cmd = $cmd + "-normal ";
  506.                 $needN = false;
  507.             }
  508.             if( $CVs[1] == $sf[1] ) {
  509.                 $cmd = $cmd + "-sf ";
  510.                 $needSF = false;
  511.             }
  512.             if( $CVs[1] == $origin[1] ) {
  513.                 $cmd = $cmd + "-origin ";
  514.                 $needOrigin = false;
  515.             }
  516.  
  517.             for ($i = 0; $i < $n; $i++) {
  518.                 $cmd = $cmd + " " + $gmtyObjs[$i];
  519.             }        
  520.             $cmd = $cmd + ";";
  521.  
  522.             if( $needEP ) {
  523.                 $cmd = $cmd + "toggle -ep -state " + $editPoints[1];
  524.                 if( $needH && ($editPoints[1] == $hulls[1] ) ) {
  525.                     $cmd = $cmd + "-hull ";
  526.                     $needH = false;
  527.                 }
  528.                 if( $needN && ($editPoints[1] == $normals[1]) ) {
  529.                     $cmd = $cmd + "-normal ";
  530.                     $needN = false;
  531.                 }
  532.                 for ($i = 0; $i < $n; $i++) {
  533.                     $cmd = $cmd + " " + $gmtyObjs[$i];
  534.                 }        
  535.                 $cmd = $cmd + ";";
  536.             }
  537.  
  538.             if( $needH ) {
  539.                 $cmd = $cmd + "toggle -hull -state " + $hulls[1];
  540.                 if( $needN && ($hulls[1] == $normals[1] ) ) {
  541.                     $cmd = $cmd + "-normal ";
  542.                     $needN = false;
  543.                 }
  544.                 for ($i = 0; $i < $n; $i++) {
  545.                     $cmd = $cmd + " " + $gmtyObjs[$i];
  546.                 }        
  547.                 $cmd = $cmd + ";";
  548.             }
  549.  
  550.             if( $needN ) {
  551.                 $cmd = $cmd + "toggle -normal -state " + $normals[1];
  552.                 for ($i = 0; $i < $n; $i++) {
  553.                     $cmd = $cmd + " " + $gmtyObjs[$i];
  554.                 }        
  555.                 $cmd = $cmd + ";";
  556.             }
  557.  
  558.             if( $needSF ) {
  559.                 $cmd = $cmd + "toggle -sf -state " + $sf[1];
  560.                 for ($i = 0; $i < $n; $i++) {
  561.                     $cmd = $cmd + " " + $gmtyObjs[$i];
  562.                 }        
  563.                 $cmd = $cmd + ";";
  564.             }
  565.  
  566.             if( $needOrigin ) {
  567.                 $cmd = $cmd + "toggle -origin -state " + $origin[1];
  568.                 for ($i = 0; $i < $n; $i++) {
  569.                     $cmd = $cmd + " " + $gmtyObjs[$i];
  570.                 }        
  571.                 $cmd = $cmd + ";";
  572.             }
  573.         }
  574.  
  575.         // Work on all the transformation objects
  576.         //
  577.         string $tfmObjs[] = `ls -tr`;
  578.         $n = size($tfmObjs);
  579.  
  580.         if( $n > 0 ) {
  581.             $cmd = $cmd + "toggle -selectHandle -state " + $selectHandles[1];
  582.             for ($i = 0; $i < $n; $i++) {
  583.                 $cmd = $cmd + " " + $tfmObjs[$i];
  584.             }
  585.             $cmd = $cmd + ";";
  586.         }
  587.     }
  588.     else if ($scope == 3) {
  589.         // Set the component display flags for all new curves
  590.         //
  591.         // toggle -nc -cv -ep -hull -state false;
  592.         $cmd = "toggle -nc -cv -state " + $CVs[2] + ";";
  593.         $cmd = $cmd + "toggle -nc -ep -state " + $editPoints[2] + ";";
  594.         $cmd = $cmd + "toggle -nc -sf -state " + $sf[2] + ";";
  595.         $cmd = $cmd + "toggle -nc -origin -state " + $origin[2] + ";";
  596.         $cmd = $cmd + "toggle -nc -hull -state " + $hulls[2] +";";
  597.     }
  598.     else if ($scope == 4) {
  599.         // Set the component display flags for all new surfaces
  600.         //
  601.         // toggle -nc -cv -ep -hull -state false;
  602.         $cmd = "toggle -ns -cv -state " + $CVs[3] + ";";
  603.         $cmd = $cmd + "toggle -ns -ep -state " + $editPoints[3] +";";
  604.         $cmd = $cmd + "toggle -ns -sf -state " + $sf[3] +";";
  605.         $cmd = $cmd + "toggle -ns -origin -state " + $origin[3] +";";
  606.         $cmd = $cmd + "toggle -ns -hull -state " + $hulls[3] +";";
  607.     }
  608.  
  609.     return $cmd;
  610. }
  611.  
  612. //
  613. //  Procedure Name:
  614. //      performDisplayControl
  615. //
  616. //  Description:
  617. //        Perform the display control command using the corresponding 
  618. //        option values.  This procedure will also show the option box
  619. //        window if necessary as well as construct the command string
  620. //        that will invoke the display control command with the current
  621. //        option box values.
  622. //
  623. //  Input Arguments:
  624. //      0 - Execute the command.
  625. //      1 - Show the option box dialog.
  626. //      2 - Return the command.
  627. //
  628. global proc string performDisplayControl(int $action)
  629. {
  630.     string $cmd = "";
  631.  
  632.     switch ($action) {
  633.  
  634.         //    Execute the command.
  635.         //
  636.         case 0:
  637.             //    Get the command.
  638.             //
  639.             $cmd = `assembleCmd`;
  640.  
  641.             //    Execute the command with the option settings.
  642.             //
  643.             eval($cmd);
  644.  
  645.             break;
  646.  
  647.         //    Show the option box.
  648.         //
  649.         case 1:
  650.             displayControlOptions;
  651.             break;
  652.  
  653.         //    Return the command string.
  654.         //
  655.         case 2:
  656.             //    Get the command.
  657.             //
  658.             $cmd = `assembleCmd`;
  659.             break;
  660.     }
  661.     return $cmd;
  662. }
  663.  
  664. // +++++++++++++++++++++++ Helper Functions ++++++++++++++++++++++++++++++++++++
  665.  
  666. global proc displayControlSetUpHelper (string $parent, int $index)
  667. {
  668.     setParent $parent;
  669.  
  670.     // Edit Points check box
  671.     //
  672.     int $editPoints[] = `optionVar -q displayControlEditPoints`;
  673.     checkBoxGrp -e -v1 $editPoints[$index] editPointsCheck;
  674.  
  675.     // Hulls check box
  676.     //
  677.     int $hulls[] = `optionVar -q displayControlHulls`;
  678.     checkBoxGrp -e -v1 $hulls[$index]  hullsCheck;
  679.  
  680.     // CVs check box
  681.     //
  682.     int $cvs[] = `optionVar -q displayControlCVs`;
  683.     checkBoxGrp -e -v1 $cvs[$index] CVsCheck;
  684.  
  685.     // Normals check box
  686.     //
  687.     if( `isTrue SurfaceUIExists` ) {
  688.         int $normals[] = `optionVar -q displayControlNormals`;
  689.         checkBoxGrp -e -v1 $normals[$index] normalsCheck;
  690.     }
  691.  
  692.     // SurfaceFaces check box
  693.     //
  694.     int $sf[] = `optionVar -q displayControlSurfaceFace`;
  695.     checkBoxGrp -e -v1 $sf[$index] SurfaceFaceCheck;
  696.  
  697.     // Origin check box
  698.     //
  699.     if( `isTrue SurfaceUIExists` ) {
  700.         int $origin[] = `optionVar -q displayControlOrigin`;
  701.         checkBoxGrp -e -v1 $origin[$index] originCheck;
  702.     }
  703.  
  704.     // Selection Handles check box
  705.     //
  706.     int $selHandles[] = `optionVar -q displayControlSelectHandles`;
  707.     checkBoxGrp -e -v1 $selHandles[$index] selectHandlesCheck;
  708. }
  709.  
  710. global proc displayControlBuild (string $parent)
  711. {    
  712.     setParent $parent;
  713.     // print ( $parent + "\n" );
  714.  
  715.     checkBoxGrp -numberOfCheckBoxes 1
  716.         -label ""
  717.         -label1 "Edit Points" editPointsCheck;
  718.  
  719.     checkBoxGrp -numberOfCheckBoxes 1
  720.         -label ""
  721.         -label1 "Hulls" hullsCheck;
  722.  
  723.     checkBoxGrp -numberOfCheckBoxes 1
  724.         -label ""
  725.         -label1 "CVs" CVsCheck;
  726.  
  727.     if( `isTrue SurfaceUIExists` ) {
  728.         checkBoxGrp -numberOfCheckBoxes 1
  729.             -label ""
  730.             -label1 "Normal (shaded mode)" normalsCheck;
  731.     }
  732.  
  733.     checkBoxGrp -numberOfCheckBoxes 1
  734.         -label ""
  735.         -label1 "Face Centers" SurfaceFaceCheck;
  736.  
  737.     if( `isTrue SurfaceUIExists` ) {
  738.         checkBoxGrp -numberOfCheckBoxes 1
  739.             -label ""
  740.             -label1 "Surface Origins" originCheck;
  741.     }
  742.  
  743.     checkBoxGrp -numberOfCheckBoxes 1
  744.         -label ""
  745.         -label1 "Sel Handles" selectHandlesCheck;
  746.  
  747.     int $childrenCount = `tabLayout -q -nch displayTabs`;
  748.     // print ( $childrenCount + "\n" );
  749.     if ($childrenCount > 2) {
  750.         // print ("one of the three parents \n");
  751.         if( `isTrue SurfaceUIExists` ) {
  752.             checkBoxGrp -e -en false normalsCheck;
  753.         }
  754.         checkBoxGrp -e -en false selectHandlesCheck;
  755.     }
  756.  
  757.  
  758.     rowLayout -nc 3 -cw 1 170 -cw 2 50 -cw 3 50 
  759.         -columnAlign  2 "center"
  760.         -columnAlign  3 "center"
  761.         -columnAttach 1 "right" 0
  762.         allOnOffLayout;
  763.     
  764.         text -l "All Options" allText;
  765.         // We need to pass in the correct parent so we are 
  766.         // adjusting the correct set of buttons
  767.         //
  768.         button -label "On" -c ("displayControlOnButtonPressed " + $parent) onButton;
  769.         button -label "Off" -c ("displayControlOffButtonPressed " + $parent) offButton;
  770.     setParent ..;
  771. }
  772.  
  773. global proc displayControlEditOptions()
  774. {
  775.     int $selectedScopeIndex = `optionMenuGrp -q -sl scopePopup`;
  776.     tabLayout -e -sti $selectedScopeIndex displayTabs;
  777. }
  778.  
  779. global proc displayControlOnButtonPressed (string $parent)
  780. {
  781.     setParent $parent;
  782.  
  783.     // Switch on all the check boxes
  784.     //
  785.     checkBoxGrp -e -v1 1 editPointsCheck;
  786.     checkBoxGrp -e -v1 1 hullsCheck;
  787.     checkBoxGrp -e -v1 1 CVsCheck;
  788.     checkBoxGrp -e -v1 1 SurfaceFaceCheck;
  789.  
  790.     if( `isTrue SurfaceUIExists` ) {
  791.         checkBoxGrp -e -v1 1 normalsCheck;
  792.         checkBoxGrp -e -v1 1 originCheck;
  793.     }
  794.  
  795.     checkBoxGrp -e -v1 1 selectHandlesCheck;
  796. }
  797.  
  798. global proc displayControlOffButtonPressed (string $parent)
  799. {
  800.     setParent $parent;
  801.     // Switch off all the check boxes
  802.     //
  803.     checkBoxGrp -e -v1 0 editPointsCheck;
  804.     checkBoxGrp -e -v1 0 hullsCheck;
  805.     checkBoxGrp -e -v1 0 CVsCheck;
  806.     checkBoxGrp -e -v1 0 SurfaceFaceCheck;
  807.     if( `isTrue SurfaceUIExists` ) {
  808.         checkBoxGrp -e -v1 0 normalsCheck;
  809.         checkBoxGrp -e -v1 0 originCheck;
  810.     }
  811.     checkBoxGrp -e -v1 0 selectHandlesCheck;
  812. }
  813.  
  814. global proc displayControlBuildButtons (string $parent)
  815. {    
  816.     setParent $parent;
  817.     // print ( $parent + "\n" );
  818.  
  819.     checkBoxGrp -numberOfCheckBoxes 1
  820.         -label ""
  821.         -label1 "Edit Points" editPointsCheck;
  822.  
  823.     checkBoxGrp -numberOfCheckBoxes 1
  824.         -label ""
  825.         -label1 "Hulls" hullsCheck;
  826.  
  827.     checkBoxGrp -numberOfCheckBoxes 1
  828.         -label ""
  829.         -label1 "CVs" CVsCheck;
  830.  
  831.     if( `isTrue SurfaceUIExists` ) {
  832.         checkBoxGrp -numberOfCheckBoxes 1
  833.             -label ""
  834.             -label1 "Normal (shaded mode)" normalsCheck;
  835.     }
  836.  
  837.     checkBoxGrp -numberOfCheckBoxes 1
  838.         -label ""
  839.         -label1 "Face Centers" SurfaceFaceCheck;
  840.  
  841.     if( `isTrue SurfaceUIExists` ) {
  842.         checkBoxGrp -numberOfCheckBoxes 1
  843.             -label ""
  844.             -label1 "Surface Origins" originCheck;
  845.     }
  846.  
  847.     checkBoxGrp -numberOfCheckBoxes 1
  848.         -label ""
  849.         -label1 "Sel Handles" selectHandlesCheck;
  850.  
  851.     int $childrenCount = `tabLayout -q -nch displayTabs`;
  852.     // print ( $childrenCount + "\n" );
  853.     if ($childrenCount > 2) {
  854.         // print ("one of the three parents \n");
  855.         if( `isTrue SurfaceUIExists` ) {
  856.             checkBoxGrp -e -en false normalsCheck;
  857.         }
  858.         checkBoxGrp -e -en false selectHandlesCheck;
  859.     }
  860.  
  861.     rowLayout -nc 3 -cw 1 170 -cw 2 50 -cw 3 50 
  862.         -columnAlign  2 "center"
  863.         -columnAlign  3 "center"
  864.         -columnAttach 1 "right" 5
  865.         allOnOffLayout;
  866.  
  867.         text -l "All Options" allText;
  868.         // We need to pass in the correct parent so we are 
  869.         // adjusting the correct set of buttons
  870.         //
  871.         button -label "On" -w 50 -c ("displayControlOnButtonPressed " + $parent) onButton;
  872.         button -label "Off" -w 50 -c ("displayControlOffButtonPressed " + $parent) offButton;
  873.     setParent ..;
  874. }
  875.  
  876.